<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;
/* @var $this yii\web\View */
/* @var $content string 字符串 */


$imgUrl=Url::to("@web/img/wx/");
$jsUrl=Url::to("@web/js/wx/");
$basejsUrl=Url::to("@web/js/");
$cssUrl=Url::to("@web/css/wx/");

?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">

    <link rel="stylesheet" href="<?=$cssUrl?>/weui.css" />
    <link rel="stylesheet" href="<?=$cssUrl?>/person_core.css" />
    <script src="<?= $basejsUrl ?>jquery.js"></script>
    <script src="<?=$basejsUrl?>/tools.js"></script>
    <script src="<?=$jsUrl?>/zepto.min.js"></script>
    <title>个人中心</title>
<script>
	function checkMobile(str) {
			var re = /^1\d{10}$/;
			if (re.test(str)) {
				return true;
			} else {
				return false;
			}
		}
		
    function sendCode(){
        var tel=$('.input_phone_number').val();
        if(tel==''){
            alert('必须输入手机号');
            return;
        }else{
			if(checkMobile(tel)==false){
				alert('请输入正确的手机号');
				return;
			}
		}
        var data={};
        data.tel=tel;
        var re=returnjson("<?=Url::to(["wx-biz/user-center-send-code-handle"])?>",data);
        if(re.flag==1){
            alert('发送验证码成功');
        }else{
            alert(re.msg);
        };
    }
    function bindtel(){
        var code=$('#txt_code').val();
        if(code==''){
            alert('必须输入验证码');
            return;
        }
        var data={};
        data.code=code;
        var re=returnjson("<?=Url::to(["wx-biz/user-center-set-tel-handle"])?>",data);
        if(re.flag==1){
            alert('绑定成功');
            window.location.reload();
        }else{
            alert(re.msg);
        };
    }
</script>
</head>

<body>

<div class="main">
    <!--当前绑定的手机号：<?=$tel?>-->
    <div class="input_phone">
        <input class="input_phone_number" type="tel" placeholder="输入您要绑定的手机号码" value="<?=$tel?>"/>
    </div>

    <div class="hr_b_div"></div>

    <div style="width: 100%; height:60px; background-color: #FFFFFF;">
        <div style="width:60%; height:60px; background-color:#99FF66; float:left;">
            <input type="text" id="txt_code" placeholder="短信验证码" style="height: 60px; width:100%; border-top: none; border-left: none; border-right:none; font-size: 1em; padding-left: 10px; border-bottom: none; float: left;"/>
        </div>
        <img src="<?= $imgUrl ?>/person_core_img/ssss.png" height="58" style="float:left; margin-left:15px;"/>
        <div onclick="sendCode()" style="width:30%; height:60px; float:right; ">
            <b style="line-height: 60px; color: #d7000f; padding-right:10px;">发送验证码</b>
        </div>
    </div>



    <div class="hr_b_div"></div>

    <div class="bd spacing" style="margin-top:40px; margin-left: 10px; margin-right: 10px;">
        <a href="javascript:;" onclick="bindtel();" class="weui_btn weui_btn_primary" style="background-color: #d7000f;">确定提交</a>
    </div>

</div>

</body>
</html>

